Usage and Max limits for pragma stack ??

Hi,

What is the use of pragma Stack? and what is the maximum limit for the same?

Thanks
A.Kumar
SystemAdmin - Wed Jan 04 03:29:05 EST 2012

Re: Usage and Max limits for pragma stack ??
Mathias Mamsch - Wed Jan 04 05:19:19 EST 2012

Hi,

pragma stack, <number> is a DXL parser instruction that will tell the DXL interpreter how much stack space (DWORDS) to reserve for a DXL program. As in all languages the stack is the place where all variables go (especially 1-dimensional arrays). The following code shows you the implication:

This code works, since DOORS will need two variables stack space on its own, and three to pass the parameters:

pragma stack, 5
 
void func(int a,b,c) {}
 
func (1,2,3)

 


Adding one parameter will give you a stack overflow:

 

 

pragma stack, 5
 
void func(int a,b,c,d) {}
 
func (1,2,3,4)



Especially if you use those 1 dimensional arrays or recursions you will need a lot of stack space. I have had no problems with doing:



 

 

// we do a lot of recursions ;-) Reserve at least 400 MB Stack Memory 
pragma stack, 100000000
ack "Note the memory usage of DOORS in the task manager before closing!"



So I would say there is only the limit of your physical memory for how much stack you reserve for your program. Hope that helps, regards, Mathias



 

 


Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS

 

Re: Usage and Max limits for pragma stack ??
SystemAdmin - Wed Jan 04 06:38:03 EST 2012

Mathias Mamsch - Wed Jan 04 05:19:19 EST 2012

Hi,

pragma stack, <number> is a DXL parser instruction that will tell the DXL interpreter how much stack space (DWORDS) to reserve for a DXL program. As in all languages the stack is the place where all variables go (especially 1-dimensional arrays). The following code shows you the implication:

This code works, since DOORS will need two variables stack space on its own, and three to pass the parameters:

pragma stack, 5
 
void func(int a,b,c) {}
 
func (1,2,3)

 


Adding one parameter will give you a stack overflow:

 

 

pragma stack, 5
 
void func(int a,b,c,d) {}
 
func (1,2,3,4)



Especially if you use those 1 dimensional arrays or recursions you will need a lot of stack space. I have had no problems with doing:



 

 

// we do a lot of recursions ;-) Reserve at least 400 MB Stack Memory 
pragma stack, 100000000
ack "Note the memory usage of DOORS in the task manager before closing!"



So I would say there is only the limit of your physical memory for how much stack you reserve for your program. Hope that helps, regards, Mathias



 

 


Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS

 

Hi Mathias,

Thanks for the detailed explanation, now I am clear on this.
One more question, I have a script with "pragma stack, 1000" I am not sure if this stack size is sufficient for the script.
I know it depend on the variables used in the script, just want to check if there are any automatic tool/feature available to check the stack size required for running script.

Best regards,
A.Kumar

Re: Usage and Max limits for pragma stack ??
Mathias Mamsch - Wed Jan 04 10:32:51 EST 2012

SystemAdmin - Wed Jan 04 06:38:03 EST 2012
Hi Mathias,

Thanks for the detailed explanation, now I am clear on this.
One more question, I have a script with "pragma stack, 1000" I am not sure if this stack size is sufficient for the script.
I know it depend on the variables used in the script, just want to check if there are any automatic tool/feature available to check the stack size required for running script.

Best regards,
A.Kumar

I would say that pragma stack, 1000000 will hurt no one regarding memory usage and be sufficient for probably all scripts, therefore my suggestion would be to incorporate that into every DXL script. Regards, Mathias

Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS

Re: Usage and Max limits for pragma stack ??
llandale - Mon Jan 09 16:01:30 EST 2012

SystemAdmin - Wed Jan 04 06:38:03 EST 2012
Hi Mathias,

Thanks for the detailed explanation, now I am clear on this.
One more question, I have a script with "pragma stack, 1000" I am not sure if this stack size is sufficient for the script.
I know it depend on the variables used in the script, just want to check if there are any automatic tool/feature available to check the stack size required for running script.

Best regards,
A.Kumar

I suggest you ignore the "stack" pragma until your program complains.

Don't recal where I got this info, but my notes say this:

pragma    stack         int
                for DOORS v8, default is  4096=2**12
                for DOORS v9, default is 16384=2**14


for whatever that's worth.

I think I've only written 2 programs that needed more than the default stack space. Trust me, that's saying a lot since I've got quite a lot of programs that do recursion and all my programs use my deep-nested library. If an average function uses 3 parameters and Mathias' post is correct, then a recursive program can handle more than 3200 recursion calls which is far more than you need for (just about) anything associated with DOORS.

If I infer correctly from Mathias' post, each "stack" value takes 4 bytes of memory.

I'm guessing that a huge reserved stack will mean you can have less module's open concurrently since DOORS has a 2gig memory limit.

I'm also guessing that nice orderly powers of 2 are reasonably desirable; perhaps to not waste any space.

 

 

  • Louie